package JDBC_Test;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.Scanner;
import org.junit.Test;
import JDBC_Test.JDBC_Util;
public class SQL_Test{
	
	@Test
	public void test1() throws SQLException{
		System.out.println("test1");
		Connection con = JDBC_Util.getConnection();
		Scanner scanner = new Scanner(System.in);
		System.out.println("请输入学生姓名");
		String studentname = scanner.next();
		System.out.println("请输入学生成绩");
		String score = scanner.next();
		String sql = "insert into students(num,name,score) values (null,?,?)";
		PreparedStatement pstmt = con.prepareStatement(sql);
		pstmt.setString(1, studentname);
		pstmt.setString(2, score);
		int res = pstmt.executeUpdate();
		System.out.println(res);
		JDBC_Util.close(pstmt, con);
		System.out.println(res);
	}
	
}
